package main;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;

import server.Server;

public class GUI implements ActionListener {
	public JFrame frame;
	public Server server;

	public GUI(Server server) {
		this.server = server;
		frame = new JFrame();
		JTextField text = new JTextField("Server is running");
		JButton button = new JButton("Close");
		frame.setLayout(new GridLayout(2, 1));
		frame.add(text);
		frame.add(button);
		button.addActionListener(this);
		frame.pack();
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		server.start();
	}

	public void actionPerformed(ActionEvent e) {
		server.killServer();
		frame.dispose();
		System.exit(0);
	}
}
